<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view(TPL_FOLDER."header");?>
<script type="text/javascript" src="{root_path}js/jquery/jquery.colorPicker-1.0.1.js"></script>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" >
  <tr>
    <td width="3%" align="left" ><img src="{tpl_path}images/forward.jpg" /></td>
    <td width="97%" align="left" >您现在的位置：<a href="<?php echo site_url(CTL_FOLDER."product");?>">产品列表</a> &gt; 添加产品</td>
  </tr>
</table>
<div id="TabAdd" style="display:none">
  <ul>
    <li><a href="#TabAdd-1"><span>基本信息</span></a></li>
    <li><a href="#TabAdd-2"><span>更多图片</span></a></li>
    <li><a href="#TabAdd-3"><span>产品内容</span></a></li>
  </ul>
  <form  action="<?php echo site_url(CTL_FOLDER."product/add_record");?>" method="post" enctype="multipart/form-data" name="dialog_add_form" id="dialog_add_form">
    <div id="TabAdd-1">
      <table width="100%"  border="0" cellpadding="3" cellspacing="0" >
        <tr>
          <td width="133"><font color="#FF0000">*</font>产品分类：</td>
          <td width="592"><select name="catalog_id" id="catalog_id">
              <option value=",0,">==根目录==</option>
              <?php foreach($catalog_list as $row) {?>
              <option value="<?php echo $row->queue;?>"><?php echo str_repeat("&nbsp;&nbsp;",$row->deep_id).$row->cat_name;?></option>
              <?php }?>
            </select>
            &nbsp;&nbsp;
            <input type="checkbox" name="is_trash" value="1" />
            放入回收站 </td>
        </tr>
        <?php if($att_id) { ?>
        <tr>
            <td width="133"><font color="#FF0000">*</font>产品属性：</td>
            <td width="592">
            <?php foreach($att_id as $row){?>
            <input type="checkbox" name="att_id[]" id="att_id" value="<?php echo $row->q_id;?>"/> <?php echo $row->title;?>
            <?php }?>
            </td>
          </tr>
          <?php }?>
        <tr>
          <td width="133"><font color="#FF0000">*</font>产品标题：</td>
          <td width="592"><input Name="title" type="text" Id="title" size="50" dataType="Require" msg="该项必须填写">
            &nbsp;
            <input type="hidden" name="title_color" id="title_color" />
            <img style="cursor:pointer" src="{tpl_path}images/color.gif"  align="absmiddle" onclick="$(this).colorPicker({ setValue:'input[name=title_color]' ,setBackground:true })" title="标题颜色" /> </td>
        </tr>
        <tr>
          <td width="133">产品价格(￥)：</td>
          <td width="592"><input Name="market_price" type="text" Id="market_price" size="10" dataType="Currency" msg="货币格式有误" Require="false"></td>
        </tr>
        <tr>
          <td width="133">产品编号：</td>
          <td width="592"><input Name="pNum" type="text" Id="pNum" size="20"></td>
        </tr>
        <tr>
          <td width="133">meta关键词：</td>
          <td width="592"><input type="text" name="keyword" maxlength="255" size="50"  /></td>
        </tr>
         <tr>
          <td>meta描述：</td>
          <td><textarea name="description" cols="50" rows="5"></textarea></td>
        </tr>
        <tr>
          <td>摘要：</td>
          <td><textarea name="summary" id="summary" cols="50" rows="5" dataType="Limit" require="false" max="250" msg="字数不超过250"></textarea></td>
        </tr>
        <tr>
          <td>上传大图：</td>
          <td><input type="text" name="pic_path2" id="pic_path2" size="25" />
            <input name="big_pic" type="file" id="big_pic" size="15" dataType="Filter" accept="<?php echo str_replace("|",",",UP_IMAGES_EXT);?>" require="false" msg="文件格式必须是：<?php echo UP_IMAGES_EXT;?>" title="上传的文件格式必须是：<?php echo UP_IMAGES_EXT;?>,且单个文件不能超过 <?php echo ini_get("upload_max_filesize");?>">
            <input type="button" name="sfbtn" class="button-style2" onclick="GetFileDialog('pic_path2')" value="选择文件" />
            &nbsp;
            <input type="checkbox" checked="checked" name="is_create_thumb" id="is_create_thumb" value="1" title="如果选择该项，则上传的缩略图将被忽略" />
            生成缩略图 &nbsp;
            <input type="checkbox" name="is_create_mark" id="is_create_mark" value="1" title="为该上传大图添加水印" />
            加水印 </td>
        </tr>
        <tr>
          <td>上传缩略图：</td>
          <td><input type="text" name="pic_path1" id="pic_path1" size="25" />
            <input name="small_pic" type="file" id="small_pic" size="15" dataType="Filter" accept="<?php echo str_replace("|",",",UP_IMAGES_EXT);?>" require="false" msg="文件格式必须是：<?php echo UP_IMAGES_EXT;?>" title="上传的文件格式必须是：<?php echo UP_IMAGES_EXT;?>,且单个文件不能超过 <?php echo ini_get("upload_max_filesize");?>,如果选择了生成缩略图，则该项将被忽略">
            <input type="button" name="sfbtn" class="button-style2" onclick="GetFileDialog('pic_path1')" value="选择文件" />
          </td>
        </tr>
        <tr>
          <td><font color="#FF0000">*</font>排序号：</td>
          <td><input name="seqorder" type="text" id="seqorder" size="4" value="0" datatype="Integer" msg="该项必须填写数字" />
          </td>
        </tr>
      </table>
    </div>
    <div id="TabAdd-2">
      <ul class="up_pic_form">
        <li>
          <input type="checkbox" value="1" name="is_create_more_mark"  />
          加水印 <img src="{tpl_path}images/notice.gif" class="tooltips" title="选择该项，则下面上传的图片将全部被加水印，上传的文件格式必须是：<?php echo UP_IMAGES_EXT;?>,且单个文件不能超过 <?php echo ini_get("upload_max_filesize");?>" /></li>
        <li><a href="javascript:extend_upload_input()" title="增加一张图片"  class="tooltips">[+]</a> 图片描述
          <input type="text" name="pic_name1" maxlength="100" size="15" />
          &nbsp; 上传图片
          <input name="more_pic1" type="file" size="15" dataType="Filter" accept="<?php echo str_replace("|",",",UP_IMAGES_EXT);?>" require="false" msg="文件格式必须是：<?php echo UP_IMAGES_EXT;?>">
          <input type="hidden" value="1" name="more_pic_id[]" />
        </li>
      </ul>
    </div>
    <div id="TabAdd-3"> <?php echo $content->create();?> </div>
    <input type="button" name="sbmit" style=" margin-left:160px; margin-bottom:10px; margin-top:10px" onclick="sub_add_form()" value="添加" class="button-style" />
  </form>
</div>
<script language="javascript">
$(document).ready(function(){
	$("#TabAdd").tabs();
	$("#TabAdd").show();
}); 
function sub_add_form(){
	var form_ob=document.getElementById("dialog_add_form"); 
	if (!Validator.Validate(form_ob,3)) return false;
	$(".up_pic_form input[type=file]").each(function(){
		if($(this).val()=='')
		{
			$(this).parent().remove();
		}
	});
	form_ob.submit();
}
//扩展上传表单
var global_loop=1;
function extend_upload_input()
{
	global_loop+=1;
	var input_ubound=$(".up_pic_form li").length-1;
	$(".up_pic_form li").eq(input_ubound).after('<li><span style="cursor:pointer; color:#FF0000" title="删除" onclick="remove_ob(this)">[-]</span> 图片描述 <input type="text"  class="inputstyle" name="pic_name'+global_loop+'" maxlength="100" size="15" /> &nbsp; 上传图片 <input class="inputstyle" name="more_pic'+global_loop+'" type="file" size="15" dataType="Filter" accept="jpg,gif,png" require="false" msg="文件格式必须是：jpg|gif|png"><input type="hidden" value="'+global_loop+'" name="more_pic_id[]" /></li>');
}
</script>
<?php $this->load->view(TPL_FOLDER."footer");?>
